package android.magical;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

public class DisplayOwnerFragment extends DialogFragment{
	
    private View view;
    
    public static DisplayOwnerFragment newInstance(){
        DisplayOwnerFragment dof = new DisplayOwnerFragment();
        return dof;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
      
    	getDialog().setTitle("Owner : type your name");
        view = inflater.inflate(R.layout.displayowner, null);
       
        ((Button)view.findViewById(R.id.btnSaveOwner)).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String owner=((TextView) view.findViewById(R.id.txtOwnerSet)).getText().toString();				
				((MainActivity)getActivity()).savePreference(owner);
				dismiss();
			}
		});		
		
        return view;
    }
}
